﻿var gulp = require('gulp'),
less = require('gulp-less'),
webpackConfig =require('./webpack.config.js'),
webpackConfigClient =require('./webpack.client.config.js'),
webpack = require('webpack-stream'),
vinylPaths = require('vinyl-paths'),
del = require('del'),
rename = require('gulp-rename'),
named = require('vinyl-named');

gulp.task('less', function() {
	gulp.src('less/*.less')
		.pipe(less())
		.pipe(gulp.dest('css'));
});

gulp.task('webpack', function() {
	del(['dist/**/*']);

	gulp.src('view/**/*-client.js')
	.pipe(named())
	.pipe(webpack(webpackConfigClient))
	.pipe(gulp.dest('dist'));
	//----
	gulp.src('view/**/*-server.js')
	.pipe(named())
	.pipe(webpack(webpackConfig))
	.pipe(gulp.dest('dist'));
});

gulp.task('watch', function() {
	//gulp.watch('less/*.less', ['less']);
	gulp.watch('view/**/*.js', ['webpack']);
});

gulp.task('default',['watch','webpack'], function() {
});
